/*
 *  $Id: Damage.cs 1024 2010-05-13 15:10:45Z thenn.erannor $
 *  This file is a part of Ragima CCG.
 *  (C) 2008 Ragima development group.
 *
 *  Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Affects {
    /// <summary>
    /// Эффект: изменение урона
    /// Параметры: значение
    /// </summary>
    public class ModDamage: Affect {
        public readonly int Value;

        public ModDamage(int value) {
            Value = value;
        }

        public override string Id {
            get { return "damage"; }
        }
        public override string NameText {
            get { return Name.GetText(Value); }
        }

        public override int BaseWeight {
            get { return Value * WeightCoeff.Damage; }
        }

        public override Affect Clone() {
            return new ModDamage(Value);
        }

        public override void SetAffect() {
            base.SetAffect();
            LocalSummary.ChangeDamage(Value);
        }
        public override void ResetAffect() {
            base.ResetAffect();
            LocalSummary.ChangeDamage(-Value);
        }
    }

    /// <summary>
    /// Эффект: изменение получаемого урона
    /// Параметры: тип урона и значение
    /// </summary>
    public class ModTakenDamage: Affect {
        public static readonly Languages.Phrase Resistance = new Languages.Phrase("affect.resistance");
        public static readonly Languages.Phrase Vulnerability = new Languages.Phrase("affect.vulnerabilty");

        public readonly DamageType DmgType;
        public readonly int Value;

        public ModTakenDamage(DamageType type, int value) {
            DmgType = type;
            Value = value;
        }

        public override string Id {
            get { return "damage.taken"; }
        }
        public override Languages.Phrase Name {
            get { return Value >= 0 ? Resistance : Vulnerability; }
        }
        public override string NameText {
            get { return Name.GetText(DmgType.AffectName, Value); }
        }

        public override int BaseWeight {
            get { return Value * (DmgType == null ? 30 : 10); }
        }

        public override Affect Clone() {
            return new ModTakenDamage(DmgType, Value);
        }

        public override void SetAffect() {
            base.SetAffect();
            LocalSummary.AddTakenDamage(this);
        }
        public override void ResetAffect() {
            base.ResetAffect();
            LocalSummary.RemoveTakenDamage(this);
        }
    }

    /// <summary>
    /// Эффект: условное изменение урона
    /// Параметры: значение
    /// </summary>
    public abstract class ConditionalModDamage: Affect {
        public readonly int Value;

        public ConditionalModDamage(int value) {
            Value = value;
        }

        public override void SetAffect() {
            base.SetAffect();
            LocalSummary.AddConditionalDamage(this);
        }
        public override void ResetAffect() {
            base.ResetAffect();
            LocalSummary.RemoveConditionalDamage(this);
        }

        public abstract bool Accept(Creature hitter, AbstractObject victim);
    }
}
